package com.wcfsy.wechat.wx.controller;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.wcfsy.wechat.wx.service.WeChatQrCodeService;
import com.wcfsy.wechat.wx.util.JsonMessage;
import com.wcfsy.wechat.wx.util.WechatUtil;

@RequestMapping("/cms/wechatqrcode/")
@Controller
public class WeChatQrCodeController {

	private static Logger logger = LoggerFactory
			.getLogger(WeChatQrCodeController.class);

	@Resource
	private WeChatQrCodeService weChatQrCodeService;

	@Resource
	private WechatUtil wechatUtil;

	/**
	 * @Title: createQrCode
	 * @Description: 生成永久二维码
	 * @param @return
	 * @return String
	 * @throws
	 */
	@RequestMapping("createQrCode")
	@ResponseBody
	public JsonMessage createQrCode(@RequestParam String channel,
			HttpServletRequest request, HttpServletResponse response) {
		try {
			return weChatQrCodeService.createQrCode(channel);
		} catch (Exception e) {
			return	JsonMessage.getSuccessJson("生成二维码失败");
		}
	}

	/**
	 * @Title: createQrPage
	 * @Description: 创建二维码页面
	 * @param @return
	 * @return String
	 * @throws
	 */
	@RequestMapping("view/page")
	public String page() {

		return "weChatQrCode/qr_code_create";
	}

}
